From 748338bb07903ba8c89457866418e4ab37c22c90 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 27 Jun 2007 20:17:54 +0100 Subject: [PATCH] hvm: Sync SVM CR4 handling with VMX. Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/svm/svm.c | 8 ++++---- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/include/asm-x86/hvm/hvm.h | 9 ++++++++- xen/include/asm-x86/processor.h | 6 ------ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 82e1bad024..e3ac5233b6 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1828,11 +1828,11 @@ static int mov_to_cr(int gpreg, int cr, struct cpu_user_regs *regs) break; case 4: /* CR4 */ - if ( value & ~mmu_cr4_features ) + if ( value & HVM_CR4_GUEST_RESERVED_BITS ) { - HVM_DBG_LOG(DBG_LEVEL_1, "Guest attempts to enable unsupported " - "CR4 features %lx (host %lx)", - value, mmu_cr4_features); + HVM_DBG_LOG(DBG_LEVEL_1, + "Guest attempts to set reserved bit in CR4: %lx", + value); svm_inject_exception(v, TRAP_gp_fault, 1, 0); break; } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 2c5d4eb35b..0f361b5877 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2387,7 +2387,7 @@ static int mov_to_cr(int gp, int cr, struct cpu_user_regs *regs) case 4: /* CR4 */ old_cr = v->arch.hvm_vmx.cpu_shadow_cr4; - if ( value & X86_CR4_RESERVED_BITS ) + if ( value & HVM_CR4_GUEST_RESERVED_BITS ) { HVM_DBG_LOG(DBG_LEVEL_1, "Guest attempts to set reserved bit in CR4: %lx", diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 5fc6a338a7..12cfcefdb0 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -302,10 +302,17 @@ static inline int hvm_event_injection_faulted(struct vcpu *v) return hvm_funcs.event_injection_faulted(v); } -/* These bits in the CR4 are owned by the host */ +/* These bits in CR4 are owned by the host. */ #define HVM_CR4_HOST_MASK (mmu_cr4_features & \ (X86_CR4_VMXE | X86_CR4_PAE | X86_CR4_MCE)) +/* These bits in CR4 cannot be set by the guest. */ +#define HVM_CR4_GUEST_RESERVED_BITS \ + ~(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | \ + X86_CR4_DE | X86_CR4_PSE | X86_CR4_PAE | \ + X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE | \ + X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT) + /* These exceptions must always be intercepted. */ #define HVM_TRAP_MASK (1U << TRAP_machine_check) diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index 2d79337f8a..6a44e505d0 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -81,12 +81,6 @@ #define X86_CR4_OSXMMEXCPT 0x0400 /* enable unmasked SSE exceptions */ #define X86_CR4_VMXE 0x2000 /* enable VMX */ -#define X86_CR4_RESERVED_BITS \ - ~(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | \ - X86_CR4_DE | X86_CR4_PSE | X86_CR4_PAE | \ - X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE | \ - X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE) - /* * Trap/fault mnemonics. */ -- 2.30.2